package com.sfzlot.dev.netty.bean;

import com.sfzlot.dev.netty.bean.bussiness.Industry;
import com.sfzlot.dev.netty.bean.bussiness.Product;
import com.sfzlot.dev.netty.bean.bussiness.Subdivide;
import com.sfzlot.dev.netty.bean.identifier.EncryptMethod;
import com.sfzlot.dev.netty.bean.identifier.ResponseIdentifier;
import com.sfzlot.dev.netty.bean.inf.Command;
import com.sfzlot.dev.netty.bean.inf.Data;

import java.io.Serializable;


/**
 * Created by ASUS on 2017/5/27.
 * 传递的信息实体
 */
public class Message implements Serializable{
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//行业大类
    private Industry industry;
    //行业细分
    private Subdivide subdivide;
    //产品类型
    private Product product;
    //版本号
    private Integer version;
	//命令标识
    private Command commandIdentifier;
    //应答标识
    private ResponseIdentifier responseIdentifier;
    //唯一识别码，VIN码
    private String vin;
    //序列号
    private Integer serial;
    //数据加密方式
    private EncryptMethod encryptMethod;
    //数据单元
    private Data data;
    //数据单元长度
    private Integer bodyLength;
    //BCC检验是否通过
    private Boolean checkPass;


	public Industry getIndustry() {
		return industry;
	}

	public void setIndustry(Industry industry) {
		this.industry = industry;
	}

	public Subdivide getSubdivide() {
		return subdivide;
	}

	public void setSubdivide(Subdivide subdivide) {
		this.subdivide = subdivide;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

    public Command getCommandIdentifier() {
		return commandIdentifier;
	}

	public void setCommandIdentifier(Command commandIdentifier) {
		this.commandIdentifier = commandIdentifier;
	}

	public ResponseIdentifier getResponseIdentifier() {
        return responseIdentifier;
    }

    public void setResponseIdentifier(ResponseIdentifier responseIdentifier) {
        this.responseIdentifier = responseIdentifier;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public Integer getSerial() {
		return serial;
	}

	public void setSerial(Integer serial) {
		this.serial = serial;
	}

	public EncryptMethod getEncryptMethod() {
        return encryptMethod;
    }

    public void setEncryptMethod(EncryptMethod encryptMethod) {
        this.encryptMethod = encryptMethod;
    }

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }

    public Integer getBodyLength() {
        return bodyLength;
    }

    public void setBodyLength(Integer bodyLength) {
        this.bodyLength = bodyLength;
    }

    public Boolean isCheckPass() {
        return checkPass;
    }

    public void setCheckPass(Boolean checkPass) {
        this.checkPass = checkPass;
    }

    

	@Override
	public String toString() {
		return "Message [industry=" + industry + ", subdivide=" + subdivide + ", product=" + product + ", version="
				+ version + ", commandIdentifier=" + commandIdentifier + ", responseIdentifier=" + responseIdentifier
				+ ", vin=" + vin + ", serial=" + serial + ", encryptMethod=" + encryptMethod + ", data=" + data
				+ ", bodyLength=" + bodyLength + ", checkPass=" + checkPass + "]";
	}

	/**
     * key中文解释，值返回code
     * @return
     */
    public String toStringCnCode() {
        return "消息内容：{" +
                "命令类型：" + commandIdentifier +
                ", 返回类型：" + responseIdentifier +
                ", 业务大类：" + industry +
                ", 业务细分：" + subdivide +
                ", 产品型号：" + product +
                ", 版本号：" + version +
                ", vin码：'" + vin + '\'' +
                ", 序列号：" + serial +
                ", 是否加密：" + encryptMethod +
                ", 数据包：" + data +
                ", 包体长度=" + bodyLength +
                ", 校验码：" + checkPass +
                '}';
    }
    
    /**
     * key和值全中文返回
     * @return
     */
    public String toStringCnMsg() {
    	String bussType = product.getComment();
    	String commandType = "";
    	if(product.equals(Product.SmartHome.POWERSWITCH)) {//智能开关
    		commandType = commandIdentifier.getCommandComment();
    	}
    	String responseType = ResponseIdentifier.getResponseIdentifier(responseIdentifier);
        return "消息内容：{" +
                "命令类型：" + commandType +
                ", 返回类型：" + responseType +
                 ", 业务大类：" + industry +
                ", 业务细分：" + subdivide +
                ", 产品型号：" + bussType +
                ", 版本号：" + version +
                ", vin码：'" + vin + '\'' +
                ", 序列号：" + serial +
                ", 是否加密：" + "不加密" +
                ", 数据包：" + data.transData() +
                ", 包体长度=" + bodyLength +
                ", 校验码：" + checkPass +
                '}';
    }
}
